package com.kim.producers.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @Project: ymdx-manage
 * @PackageName: com.ymdx.manage.rabbitmq
 * @FileName: DriverRabbitmq.java
 * @Description: The DriverRabbitmq is...
 * @Author: kimwu
 * @Time: 2020-11-09 16:03:45
 */
@Slf4j
@Service
public class DriverRabbitmqServce {

    /**
     * exchange交换器名字
     */
    @Value("${rabbitmq.dlx.exchange}")
    private String driverUpExchangeName;
    /**
     * 路由键名字
     */
    @Value("${rabbitmq.dlx.routingkey}")
    private String driverUpRoutingKey;

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendDriverMessage(String driverNumber) {
        //向消息队列发送消息
        //参数一 ： 交换器   参数三 ： 消息
        this.rabbitTemplate.convertAndSend(driverUpExchangeName, driverUpRoutingKey, driverNumber);
        log.info("向消息队列发送消息 {}", driverNumber);
    }
}
